<%--
  Created by IntelliJ IDEA.
  User: xiaoyuyu
  Date: 2019/7/27
  Time: 11:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>
        超市管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="./css/x-admin.css" media="all">
    <link rel="stylesheet" href="../../lib/layui/myicon/iconfont.css">
    <style>
        .upload-div{
            margin: 20px;
        }
        #msg{
            color: red;
        }
    </style>
</head>
<body>
<div class="upload-div">

    <input type="file" lay-type="file" id="upload" name="file" lay-title="请选择文件" class="layui-upload-file">
    <table id="msg" style="margin-top: 10px;">

    </table>


</div>


<script src="../../lib/layui/layui.js" charset="utf-8">
</script>
<script src="../../js/x-layui.js" charset="utf-8">
</script>
<script src="../../js/jquery.min.js" charset="utf-8"></script>
<script src="../../js/chaoshi.js" charset="utf-8"></script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        upload({
            url: '${pageContext.request.contextPath}/importEmployeeExcel'
            ,ext: 'xls|xlsx|XLS|XLSX' //那么，就只会支持这三种格式的上传。注意是用|分割。
            ,before: function(input){
                //返回的参数item，即为当前的input DOM对象
                // console.log('文件上传中');
                $("#msg").replaceWith("<table id=\"msg\" style=\"margin-top: 10px;\"></table>");
                $("#msg").append("<tr><td>文件上传中</td></tr>");
            }
            ,success: function(res){
                console.log(res); //上传成功返回值，必须为json格式

                var msg = res.msg;
                var results = new Array();
                results = msg.split("|");
                $("#msg").replaceWith("<table id=\"msg\" style=\"margin-top: 10px;\"></table>");
                for(var i=0;i<results.length;i++){
                    $("#msg").append("<tr><td>"+ results[i] +"</td></tr>");
                }
                parent.location.replace(parent.location.href);

            }
        });
    });
</script>
</body>
</html>
